package com.zy.controller;

import com.zy.entity.User;
import com.zy.service.UserService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController
{

    @Autowired
    private UserService userService;

    /**
     * 查找用户列表
     * @param user
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/userList")
    public Map<String,Object> userList(User user, int pageNo, int pageSize)
    {
        return userService.findUserList(user,pageNo,pageSize);
    }

    /**
     * 新增用户
     * @param user
     */
    @PostMapping("/addUser")
    public Map<String,Object> userList(@RequestBody User user)
    {
        return userService.addUser(user);
    }

    /**
     * 删除用户
     * @param id
     */
    @DeleteMapping("/deleteUser")
    public int deleteUser(int id)
    {
        return userService.deleteUser(id);
    }

}
